<route lang="jsonc" type="page">{
  "layout": "default",
  "style": {
    "navigationBarTitleText": "选择生日",
  },
}</route>

<script lang="ts" setup>
import { updateBirthdayApi, getUserInfoApi } from '@/api'



/* 生日 */
const value = ref<number>()

 
 

/* 挂载的时候请求个人信息，回显性别 */
onMounted(async () => {
  const _res = await getUserInfoApi();
  // gender.value = _res.gender;
  value.value = new Date(_res.birthday).getTime()
})

/* 更新性别 */
const nextStep = async () => {
  console.log("valuevaluevalue",value)
 
  if (!value) {
    return;
  }
  try {
    uni.showLoading({
      title: '更新中...',
    });
    await updateBirthdayApi(value.value);
    uni.showToast({
      title: '更新成功',
      icon: 'success',
      duration: 2000,
    });

    /* 跳到tabbar页面，pages/index/index */
  uni.switchTab({
    url: '/pages/index/index',
  });

    // uni.navigateBack();
  } catch (error) {
    uni.hideLoading();
  }

}

</script>

<template>
  <div style="padding-top: 208rpx; padding-left: 50rpx; padding-right: 50rpx">
    <div class="color-#000000 text-48rpx fon-500">如实选择生日</div>
    <div class="mt-16rpx color-#999999 text-28rpx">
      你的幸运日来临时兔兔才会闪光振动
    </div>
    <div class="color-#999999 text-28rpx">您所选择的信息我们将严格保密</div>

    <div class="mt-160rpx">

      <wd-datetime-picker-view  :minDate="-604859444000" :maxDate="Date.now()" type="date" v-model="value" label="年月" />



    </div>

    <div style="position: fixed; bottom: 72rpx; left: 50rpx;" class="w-650rpx h-102rpx">
      <wd-button    block custom-style="height: 102rpx" @click="nextStep">下一步</wd-button>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.gender_ch {
  border-radius: 30rpx 30rpx 30rpx 30rpx;
  border: 2rpx solid #d9d9d9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.is-active {
  border: 2rpx solid #FF0800;
}
</style>
